#https://leetcode.cn/problems/longest-substring-without-repeating-characters/solutions/784288/3wu-zhong-fu-zi-fu-de-zui-chang-zi-chuan-4q2y/

class Solution {
public:
        int lengthOfLongestSubstring(string s) {
        vector<int> m(128, 0);
        int ans = 0;
        int i = 0;
        for (int j = 0; j < s.size(); j++) {
            ++m[s[j]];
            while(m[s[j]]==2){
                --m[s[i++]];
            }
            ans = max(ans, j - i + 1);
        }
        return ans;
    }
};